/******************************************************************************
*
* This file is part of FreeTrack (http://code.google.com/p/qtfreetrack).
* BY Willy Gardiol (willy@gardiol.org)
*
* FreeTrack is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* FreeTrack is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Foobar.  If not, see <http://www.gnu.org/licenses/>
*
******************************************************************************/

#ifndef WORKERPROCESS_H
#define WORKERPROCESS_H

#include "IncFreeTrack.h"
#include "ftlabel.h"

class WorkerProcess : public QObject
{
    Q_OBJECT
public:
    explicit WorkerProcess(int);
    // Say true when do_stuff has terminated
    bool isTerminated();
    QString getErrorString();

    bool run(const QString& title);

public slots:
    void pleaseTerminate();

protected:
    // will be true when a termination is requested
    bool please_terminate;

    virtual bool do_stuff();

    void setErrorString(const QString&);
    void sendUpdate(const QString &update, int who, int min, int max, int curr);

private:
    bool still_running;
    bool error;
    QString error_string;
    int n_progress_bars;
    QList<QProgressBar*> wait_progresses;
    QList<FTLabel*> wait_progress_labels;

};

#endif // WORKERPROCESS_H
